//
//  ZYCAttendanceSummaryBottomView.m
//  ZDSC
//
//  Created by 张威 on 2021/10/26.
//

#import "ZYCAttendanceSummaryBottomView.h"
@interface ZYCAttendanceSummaryBottomView ()

@property (nonatomic, strong) UILabel *progressLabel;
@property (nonatomic, strong) UIProgressView *progressView;
@property (nonatomic, strong) UIButton *comfirmButton;
@end
@implementation ZYCAttendanceSummaryBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        [self addSubview:self.progressLabel];
//        [self addSubview:self.progressView];
        [self addSubview:self.comfirmButton];
        
//        [self.progressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.equalTo(self);
//            make.top.equalTo(self).offset(44.0f);
//        }];
//
//        [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.equalTo(self);
//            make.size.mas_equalTo(CGSizeMake(240.0f, 19.0f));
//            make.top.equalTo(self.progressLabel.mas_bottom).offset(8.5f);
//        }];
        
        [self.comfirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(240.0f, 40.0f));
        }];
    }
    return self;
}


- (UILabel *)progressLabel {
    if (!_progressLabel) {
        _progressLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 14.0f) titleColor:HEX_RGB(@"#666666") textAlignment:ZZTextAlignmentCenter];
        _progressLabel.text = @"导出中78%";
    }
    return _progressLabel;
}

- (UIProgressView *)progressView {
    if (!_progressView) {
        _progressView = [[UIProgressView alloc] init];
        _progressView.progressTintColor = HEX_RGB(@"#00A556");
        _progressView.trackTintColor = HEX_RGB(@"#E5E5E5");
        _progressView.progress = 0.78f;
        _progressView.layer.cornerRadius = 8.5f;
        _progressView.layer.masksToBounds = YES;
    }
    return _progressView;
}


- (UIButton *)comfirmButton {
    if (!_comfirmButton) {
        _comfirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _comfirmButton.frame = CGRectMake(0,0, kScreenWidth - 2 * 66, 40);
        [_comfirmButton setTitle:@"导出报表" forState:UIControlStateNormal];
        [_comfirmButton setTitleColor:HEX_RGB(kTitleWhiteColor) forState:UIControlStateNormal];
//        _comfirmButton.backgroundColor = HEX_RGB(@"#41B166");
        _comfirmButton.titleLabel.font = kCustomFont(@"PingFangSC-Regular", 16.0f);
        [_comfirmButton addTarget:self action:@selector(clickComfirmAction:) forControlEvents:UIControlEventTouchUpInside];
        _comfirmButton.layer.cornerRadius = 20;
        _comfirmButton.layer.masksToBounds = YES;
        CAGradientLayer *gradientLayer = [CAGradientLayer layer];
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(1, 0);
        gradientLayer.colors = @[(__bridge id)HEX_RGB(@"#F7F0B9").CGColor,
                                 (__bridge id)HEX_RGB(@"#00A556").CGColor];
        gradientLayer.locations = @[@(0.3),@(1.0f)];
        gradientLayer.frame = _comfirmButton.bounds;
        gradientLayer.cornerRadius = 20;
        [_comfirmButton.layer insertSublayer:gradientLayer atIndex:0];
    }
    return _comfirmButton;
}

- (void)clickComfirmAction:(UIButton *)sender{
    if ([self.delegate respondsToSelector:@selector(attendanceSummaryBottomViewDidExportExcel)]) {
        [self.delegate attendanceSummaryBottomViewDidExportExcel];
    }
}
@end
